<!--
 * @Author: zhang ke
 * @Date: 2025-07-03 21:28:34
 * @LastEditors: your name
 * @LastEditTime: 2025-07-03 22:27:45
 * @Description: 
 * @FilePath: \vue3-admin\src\views\screen\components\Top.vue
-->
<!-- 数据大屏的头部 -->
 <template>
    <div class="top-wrapper">
        <div class="left">
            <div class="btn" @click="goHome">首页</div>
        </div>
        <div class="content">智慧旅游可视化大数据展示平台</div>
        <div class="right">
            <div class="btn">统计报告</div>
            <div class="time">当前时间： {{ time }}</div>
        </div>
    </div>
 </template>
 <script setup lang="ts">
 import {ref,onMounted,onBeforeUnmount} from 'vue'
 import moment from 'moment';
 import {useRouter} from 'vue-router'
 let time = ref()
 let timer = ref()
 let router = useRouter()
onMounted(()=>{
  timer.value =  setInterval(()=>{
         time.value = moment(new Date()).format('YYYY年MM月DD HH:mm:ss');
         console.log('执行中')
    },1000)
})
//跳转到首页
const goHome = ()=>{
    router.push('/home')
}
//离开页面卸载
onBeforeUnmount(()=>{
    clearInterval(timer.value)
    
})
 </script>
 <style scoped lang="scss">
.top-wrapper{
    width: 100%;
    height: 48px;
    display: flex;
    .left{
        flex: 1;
        background: url('../images/dataScreen-header-left-bg.png') no-repeat;
        background-size: cover;
        display: flex;
        justify-content: flex-end;
        .btn{
            width:150px;
            height: 100%;
            text-align: center;
            line-height: 46px;
            background: url('../images/dataScreen-header-btn-bg-l.png') no-repeat;
            background-size:cover;
            color: #0990b4;
            cursor:pointer;//鼠标变成小手
        }
    }
    .content{
        height: 92px;
        flex: 2;
        background: url('../images/dataScreen-header-center-bg.png') no-repeat;
        background-size: cover;
        line-height: 80px;
        font-size: 35px;
        font-weight: bold;
        text-align: center;
         color: #0990b4;
         letter-spacing: 1.5px;//字间距
    }
    .right{
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex: 1;
        background: url('../images/dataScreen-header-right-bg.png') no-repeat;
        background-size: cover;
        .btn{
            width:155px;
            height: 100%;
            text-align: center;
            line-height: 46px;
            background: url('../images/dataScreen-header-btn-bg-r.png') no-repeat;
            background-size:cover;
            color: #0990b4;
        }
        .time{
            color: #0990b4;
            font-size: 16px;
            margin-right: 10px;
        }
    }
}
 </style>